package com.wmb.service.impl;

import com.wmb.bean.UserInfoBean;
import com.wmb.dao.UserInfoBeanMapper;
import com.wmb.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    // 依赖注入dao层接口
    @Resource
    private UserInfoBeanMapper userInfoBeanMapper;

    @Override
    public boolean doLogin(UserInfoBean userInfoBean) {
        // 调用dao层中的方法进行登录验证业务逻辑处理，通过service类中的方法去调用bao层接口中的方法，并返回结果
        UserInfoBean userInfoBean1 = userInfoBeanMapper.doLogin(userInfoBean);
        System.out.println("mybatis查询结果：" + userInfoBean1);
        return userInfoBean1 != null;
    }

    @Override
    public int addAndUpdateUserInfo(UserInfoBean userInfoBean) {
        // 默认返回值
        int i = 0;
        // 调用dao层进行数据库操作处理
        i = userInfoBeanMapper.insertSelective(userInfoBean);
        return i;
    }

    public void setUserInfoBeanMapper(UserInfoBeanMapper userInfoBeanMapper) {
        this.userInfoBeanMapper = userInfoBeanMapper;
    }

    public UserInfoBeanMapper getUserInfoBeanMapper() {
        return userInfoBeanMapper;
    }
}
